package com.darren.euc.dao.impl;


import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.springframework.stereotype.Repository;

import com.darren.euc.dao.SystemDao;
import com.darren.euc.entity.SystemParameter;


@Repository
public class SystemDaoImpl extends BaseDaoImpl<SystemParameter, Integer> implements SystemDao {
	
	@SuppressWarnings("unchecked")
	@Override
	public List<SystemParameter> getAll() {
		Session session = sessionFactory.getCurrentSession();	
		return (List<SystemParameter>)session.createQuery("from SystemParameter").list();
	}
	
	@Override
	public void generateMessage(){
		Session session = sessionFactory.getCurrentSession();	
		session.doWork(new Work() {			
			@Override
			public void execute(Connection connection) throws SQLException {
				// TODO Auto-generated method stub
				CallableStatement  callableStatement = connection.prepareCall("{call usp_generate_message}");
				callableStatement.execute();
			}
		});
	}

}